//@ts-nocheck
import { createApp } from 'vue';
import 'element-plus/dist/index.css'; // 确保 Element Plus 样式优先加载
import 'element-plus/theme-chalk/dark/css-vars.css'
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persist';
import './assets/main.css';
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import App from './App.vue';
import router from './router';
import { PerfectScrollbarPlugin } from 'vue3-perfect-scrollbar';
import 'vue3-perfect-scrollbar/style.css';


//1 预览组件以及样式
import VMdPreview from '@kangc/v-md-editor/lib/preview';
import '@kangc/v-md-editor/lib/style/preview.css';
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';

import hljs from 'highlight.js';
import Prism from 'prismjs';

import createLineNumbertPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index';

import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';
import createAlignPlugin from '@kangc/v-md-editor/lib/plugins/align';

// ================================================================
const app = createApp(App);

// 全局注册 Element Plus 图标
Object.entries(ElementPlus).forEach(([key, component]) => {
    if (key.endsWith('Icon')) app.component(key, component);
});

// 导入 pinia 库
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
app.use(pinia);

app.use(router);
app.use(ElementPlus, { locale: zhCn });

app.use(PerfectScrollbarPlugin);

// 全局引入 axios 和 api
import milliaAxios from "@/api/milliaAxios";
app.config.globalProperties.$milliaAxios = milliaAxios;
import api from "@/api/api";
app.config.globalProperties.$millaApi = api;

VMdPreview.use(vuepressTheme, {
    Prism,
    Hljs: hljs,
});

VMdPreview.use(createLineNumbertPlugin())
VMdPreview.use(createCopyCodePlugin())
VMdPreview.use(createAlignPlugin())

app.use(VMdPreview)

app.mount('#app');